<template>
  <div>
    <a-select style="width:100%" :allowClear="true" @change="onChange" v-model="args" mode="multiple" :placeholder="i18n('predicate.method','HTTP请求方法')">
      <a-select-option value="POST">POST</a-select-option>
      <a-select-option value="GET">GET</a-select-option>
    </a-select>
  </div>
</template>

<script>
  export default {
    name: "MethodEdit",
    props: ["value"],
    data() {
      return {
        args: ""
      }
    },
    created() {
      this.init();
    },
    methods: {
      i18n(name,text,key){
          return this.$ti18(name,text,"SysRouting",key);
      },
      init() {
        if (this.value.predicateArgs.length>0) {
          var predicateArgs=JSON.parse(this.value.predicateArgs);
          var predicateArgsAry = [];
          var ary = [];//用于转换数组
          for (var index in predicateArgs) {
            ary.push({[index]: (predicateArgs)[index]})
          }
          for (var j = 0; j < ary.length; j++) {
            predicateArgsAry.push(ary[j]["_genkey_" + j]);
          }
          this.args =predicateArgsAry;
        } else {
          this.args =[];
        }
      },
      onChange() {
        var obj={};
        for (var i = 0; i < this.args.length; i++) {
          obj["_genkey_"+i]=this.args[i];
        }
        this.value.predicateArgs=JSON.stringify(obj);
      }
    },
  }
</script>

<style scoped>

</style>